package com.hundsun.cprs.yyt.gateway.service.uc;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;
/**
 * 清算中心子渠道简单工厂实现类
 * @author herong22384
 * @date 20190617
 *
 * */
@Component
public class ClearingChannelFactory implements ApplicationContextAware {
    private Map<String, ClearingChannelService> clearingChannelServiceMap = new HashMap<String,ClearingChannelService>();

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        //加载所有清算中心银行子渠道处理器
        Map<String, ClearingChannelService> beanMap = applicationContext.getBeansOfType(ClearingChannelService.class);
        for(ClearingChannelService bean : beanMap.values()){
            clearingChannelServiceMap.put(bean.getChannelBankNo(), bean);
        }
    }

    public ClearingChannelService getBankBindingService(String bankNo){
        return clearingChannelServiceMap.get(bankNo);
    }
}
